package org.paradise.dms.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.paradise.dms.pojo.SystemUserGroup;
import org.springframework.stereotype.Service;

import com.dheaven.framework.dao.BaseHibernateDao;
import com.dheaven.framework.dao.DaoException;

@Service
public class SystemUserGroupMgrDAOImpl extends BaseHibernateDao<SystemUserGroup> {

	private static Logger log = Logger.getLogger(SystemUserGroupMgrDAOImpl.class);

	/**
	 * 
	 * Description: 根据systemusergroupname查找该用户组是否存在
	 * 
	 * @Version1.0 2009-4-4 下午03:46:09 李双江（paradise.lsj@gmail.com）创建
	 * @param systemusergroupname
	 * @return
	 * @throws DaoException
	 */
	@SuppressWarnings("unchecked")
	public List<SystemUserGroup> getSystemUserGroupByName(String systemusergroupname) throws DaoException {
		return this.find("from SystemUserGroup sug where sug.systemusergroupname=?", new Object[] { systemusergroupname });
	}

	/**
	 * 
	 * Description:插入一条系统用户。同时返回含有该系统用户的list对象
	 * 
	 * @Version1.0 2009-4-4 下午03:53:35 李双江（paradise.lsj@gmail.com）创建
	 * @param sug
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<SystemUserGroup> insertSystemUserGroup(SystemUserGroup sug) {
		try {
			this.create(sug);
			return this.find("from  SystemUserGroup where systemusergroupname=?", new Object[] { sug.getSystemusergroupname() });
		} catch (DaoException e) {
			log.error(e);
		}
		return null;
	}

}
